import { loadTIME } from './cache' // 判断登录是否过期的时间

// 判断是否是微信浏览器
export function IsWeiXin () {
  var ua = window.navigator.userAgent.toLowerCase()
  if (ua.match(/MicroMessenger/i) == 'micromessenger') {
    return true
  } else {
    return false
  }
}

// 判断登录时间是否过期
export function TimeExpired () {
  if (loadTIME() === undefined || loadTIME() + 2592000000 < new Date().getTime()) {
    if (IsWeiXin()) {
      // 测试
      window.location = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxae1d85bfd66812e6&redirect_uri=https%3A%2F%2Fynwx.zgwyzxw.cn%2F&response_type=code&scope=snsapi_userinfo&state=89e0440c0f961acf72521cda57d897f0#wechat_redirect'
      // 正式
      // window.location = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx07bb0836a18cbb59&redirect_uri=https%3A%2F%2Fynzx.zgwyzxw.cn%2F&response_type=code&scope=snsapi_userinfo&state=89e0440c0f961acf72521cda57d897f0#wechat_redirect'
    } else {
      this.$router.push('/Login')
    }
  }
}
